<template>
  <div class="detail">
      <!-- 标题 -->
     <div class="van-doc-nav-bar van-nav-bar van-hairline--bottom" style="z-index: 1;">
         <div class="van-nav-bar__left"  @click="$router.go(-1)">
             <i class="van-icon van-icon-arrow-left van-nav-bar__arrow"><!----></i>
             返回
        </div>
        <div class="van-nav-bar__title van-ellipsis">商品详情</div>
    </div>

    <!--  -->
    <img :src="getDetailGoodsInfo.IMAGE1">
    <div class="price">
        <p>{{getDetailGoodsInfo.NAME}}</p>
        <p>价格：￥{{getDetailGoodsInfo.PRESENT_PRICE}}.0元</p>
    </div>

    <div class="nav">
        <ul>
            <li :class="active" @click="show()">商品详情</li>
            <li :class="active1" @click="show1()">评论</li>
        </ul>
    </div>
    
    <div v-html="getDetailGoodsInfo.DETAIL" v-if="bool">

    </div>
    <div v-else>
        123
    </div>

    <!-- <button @click="reduce()">减少</button> -->

    <div class="submit">
        <router-link to="">
            <div class="join" @click="showCart()">加入购物车</div>
        </router-link>
        <router-link to="">
            <div class="directPurchase" @click="buy()">直接购买</div>
        </router-link>
    </div>
  </div>

</template>

<script>

// import * as indexRequest from "@/commonAPI/api.js"
import { getDetailData } from "@/commonAPI/api.js"

export default {
    props:["id"],
    data(){
        return {
            Id:this.id,
            getDetailGoodsInfo:{},
            active:"active",
            active1:"",
            bool:"true"
        }
    },
  methods:{
      async DataUrl(){
          var that = this
      // let info = await indexRequest.GetData(url)
       let config = {
           goodsId:that.Id
        }
        // window.console.log(config.goodsId)
      let res = await getDetailData("/goods/getDetailGoodsInfo",config)
    //   window.console.log(res)
      this.getDetailGoodsInfo = res
    //   window.console.log(this.getDetailGoodsInfo.DETAIL)
    },
          show(){
              this.active ='active'
              this.active1 ='',
              this.bool = true
          },
          show1(){
              this.active1 ='active'
              this.active ='',
                this.bool = false
          },

          showCart(){

          },
          buy(){
              this.$store.dispatch("addShop",{id:this.getDetailGoodsInfo.ID,name:this.getDetailGoodsInfo.NAME,price:this.getDetailGoodsInfo.PRESENT_PRICE,image:this.getDetailGoodsInfo.IMAGE1,total:this.getDetailGoodsInfo.PRESENT_PRICE,allTotal:0,isTrue:false})
          },
          reduce(){
                this.$store.dispatch("reduceShop",{id:this.getDetailGoodsInfo.ID})
          }
  },
  created(){
    var that = this
    that.DataUrl()
  }
};
</script>

<style lang="scss" scoped>
    .detail{
        margin-bottom: 70px;
        .van-nav-bar{
            width: 100%;
            position: fixed;
            left: 0;
            top: 0;
        }
        img{
            width: 100%;
        }
        .price{
            font-size: 18px;
            background-color: white;
            margin-top: 5px;
            font-weight: 550;
            color: black;
            border-bottom: 1px solid #eeeeee;
        }
        .nav{
            ul{
                display: flex;
                text-align: center;
                li{
                    flex: 1;
                    font-size: 16px;
                    height: 50px;
                    line-height: 50px;
                    background-color: white;
                    border:none;
                    &:hover{
                        color: red;
                        border-bottom: 2px solid red;
                    }
                }
                .active{
                    color: red;
                    border-bottom: 2px solid red;
                }
            }
        }
        .submit{
            width: 100%;
            position: fixed;
            left: 0;
            bottom: 50px;
            display: flex;
            background-color: white;
            div{
                flex: 1;
                padding: 15px 52px;
                margin: 5px;
                font-size: 16px;
                color: white;
                border-radius: 5px;
                text-align: center;
                background-color: red;
            }
            .join{
                background-color: green;
            }
        }
    }
</style>